package vcp.gui.forms;

import javax.swing.JPanel;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.util.Vector;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

import vcp.gui.components.VCPPanel;
import javax.swing.ListSelectionModel;

public class ResolveComplaintsForm extends VCPPanel {
	private static final int N_ROWS = 8;
    private static String[] header = {"Customer ID", "Order ID", "Title", "Resolved"};
    private DefaultTableModel dtm = new DefaultTableModel(null, header) {

        @Override
        public Class<?> getColumnClass(int col) {
            return getValueAt(0, col).getClass();
        }
        @Override
        public boolean isCellEditable(int row, int col) {
        	switch (col) {
            case 3:
                return true;
            default:
                return false;
         }
        }
    };
    private JTable table = new JTable(dtm);
    private JScrollPane scrollPane = new JScrollPane(table);
    private JScrollBar vScroll = scrollPane.getVerticalScrollBar();
    private int row;
    private boolean isAutoScroll;
	/**
	 * Create the panel.
	 */
	public ResolveComplaintsForm() {
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		setLayout(new GridLayout(2, 1, 0, 0));
		this.setLayout(new BorderLayout());
       // Dimension d = new Dimension(320, N_ROWS * table.getRowHeight());
       // table.setPreferredScrollableViewportSize(d);
        /*
        for (int i = 0; i < N_ROWS; i++) {
            addRow();
        }
        */
        scrollPane.setVerticalScrollBarPolicy(
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
           /* vScroll.addAdjustmentListener(new AdjustmentListener() {

                @Override
                public void adjustmentValueChanged(AdjustmentEvent e) {
                    isAutoScroll = !e.getValueIsAdjusting();
                }
            });
            */
            this.add(scrollPane, BorderLayout.CENTER);
            /*
            JPanel panel = new JPanel();
            panel.add(new JButton(new AbstractAction("Add Row") {

                @Override
                public void actionPerformed(ActionEvent e) {
                    addRow();
                }
            }));
            this.add(panel, BorderLayout.SOUTH);
		    */
		//table = new JTable(new DefaultTableModel());
       // table.setPreferredScrollableViewportSize(new Dimension(500, 70));
        //table.setFillsViewportHeight(true);		
		//JScrollPane scrollPane = new JScrollPane(table);
		//add(scrollPane);
	}
	/*
	private void addRow() {
        char c = (char) ('A' + row++ % 26);
        dtm.addRow(new Object[]{
                Character.valueOf(c),
                String.valueOf(c) + String.valueOf(row),
                Integer.valueOf(row),
                Boolean.valueOf(row % 2 == 0)
            });
    }
    */
	public DefaultTableModel getDtm() {
		return dtm;
	}
	public void setDtm(DefaultTableModel dtm) {
		this.dtm = dtm;
	}
	public JTable getTable() {
		return table;
	}
	public void setTable(JTable table) {
		this.table = table;
	}


	
}
